<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>遮罩</title>
<style>
 #blanks{
  display:none;
  width:100%;
  //height:100%;
  height:100px;
  position:absolute;
  top:0;
  background-color:#ccc;
  z-index:1000;
  -moz-opacity: 0.7; 
  opacity:.70; 
  filter: alpha(opacity=70);
 }
 #login{
  padding:18px;
  display:none;
  background-color:pink;
  width:300px;
  height:100px;
  position:absolute;
  left:400px;
  top:20%;
  z-index:1001;
 }
</style>
</head>
<body onload="setHeight()">
  <div id="content">
   <input type="button" value="登陆" onclick="showLogin()">

  </div>
  <div id="blanks"></div>
  <div id="login">
   <form method="post">
    用户名：<input type="text" name="username" ><br/>
    密  码：<input type="password" name="password"><br/>
     <input type="submit" value="提交">
   </form>
    <div id="btnclose" style="position:absolute;left:93%;top:0%;z-index:5;">
     <img src="close.png" onclick="hidediv();"/>
    </div>
  </div>
</body>
</html>
<script type="text/javascript">
 function setHeight()
 {
  var h=document.documentElement.scrollHeight;
  document.getElementById("blanks").style.height=h+"px";
 }
 function hidediv()
 {
  document.getElementById("login").style.display="none";
  document.getElementById("blanks").style.display="none";
 }
 function showLogin()
 {
  document.getElementById("login").style.display="block";
  document.getElementById("blanks").style.display="block";
 }
</script>